package com.jinlia.show.modules.wxapp.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jinlia.show.modules.base.system.entity.GoodsType;
import com.jinlia.show.modules.base.model.po.GoodsTypePO;
import com.jinlia.show.modules.base.model.query.GoodsTypeQuery;
import com.jinlia.show.modules.base.model.po.GoodsPO;
import com.jinlia.show.modules.base.system.service.GoodsTypeMapperService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequiredArgsConstructor
@RequestMapping("/category")
public class CategoryController {
      @Autowired
    private GoodsTypeMapperService goodsTypeMapperService;

    /**
     * @return
     */
    @PostMapping("list")
    public ResponseEntity<List<GoodsType>> companyList() {
        List<GoodsType> list = goodsTypeMapperService.lambdaQuery()
                .list();
        return ResponseEntity.ok(list);
    }

    /**
     * 分类标签
     * @param goodsTypeQuery
     * @return
     */
    @PostMapping("list/vo")
    public ResponseEntity<List<GoodsTypePO>> listGroup(@RequestBody GoodsTypeQuery goodsTypeQuery) {
        List<GoodsTypePO> listGroup = goodsTypeMapperService.goodsListPO(goodsTypeQuery);
        return ResponseEntity.ok(listGroup);
    }

    /**
     *
     */
    @PostMapping("goods/list")
    public ResponseEntity<IPage<GoodsPO>> goodsList(@RequestBody GoodsTypeQuery goodsTypeQuery) {
        Page<GoodsPO> goodsPOPage = goodsTypeMapperService.goodsList(goodsTypeQuery);
        return ResponseEntity.ok(goodsPOPage);
    }
}
